package com.lanou.myapp.main;


import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.os.Handler;
import android.widget.TextView;

import com.lanou.myapp.R;


/**
 * Created by dllo on 16/1/11.
 */
public class GuidePageActivity extends AppCompatActivity {
    private ImageView imageView;
    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);
        imageView = (ImageView) findViewById(R.id.iv_first);
        textView = (TextView) findViewById(R.id.tv_first);
        final Handler handler = new Handler(new Handler.Callback() {
            @Override
            public boolean handleMessage(Message msg) {
                switch (msg.what) {
                    case 1:
                        imageView.setImageResource(R.mipmap.img_guide_p1);
                        textView.setText("每   日   一   读");
                        break;
                    case 3:
                        imageView.setImageResource(R.mipmap.img_lauch_bitch);
                        textView.setText("每   日   一   笑");
                        break;
                    case 5:
                        Intent intent = new Intent(GuidePageActivity.this, MainActivity.class);
                        startActivity(intent);
                        finish();
                        break;
                }
                return false;
            }
        });


        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i < 6; i++) {
                    try {
                        Thread.sleep(1000);
                        handler.sendEmptyMessage(i);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();

    }

}
